package net.chrisrichardson.ormunit.hibernate;

import junit.framework.Assert;

import org.hibernate.engine.CascadeStyle;
import org.hibernate.mapping.Property;
import org.hibernate.util.ArrayHelper;

public class FieldMapping {

	protected Property property;

	public FieldMapping(Property property) {
		this.property = property;
	}

	public void assertCascade(CascadeStyle cascade) {
		CascadeStyle actualCascade = this.property.getCascadeStyle();
		if (actualCascade instanceof CascadeStyle.MultipleCascadeStyle)
			Assert.assertEquals(ArrayHelper.toString(new Object[] { cascade }),
					actualCascade.toString());
		else
			Assert.assertEquals(cascade.toString(), actualCascade.toString());
	}

}